<?php
header('content-type:text/html;charset=utf8');
$name = $_POST['name'];
$tel = $_POST['tel'];
$password = $_POST['password'];
$con = mysqli_connect("localhost","root","root","ikea");
$res = mysqli_query($con,"select * from user where name=\"$name\"");
$row = mysqli_fetch_assoc($res);
if($row){
    $arr =[
        "meta"=>[
            "status"=>1,
            "msg"=>"用户名被占用"
        ]
        ];
}else{
    $bool = mysqli_query($con,"insert user(name,tel,password) values('$name',$tel,'$password')");
    if($bool){
        $arr =[
            "meta"=>[
                "status"=>2,
                "msg"=>"注册成功"
            ]
        ];
    }else{
        $arr =[
            "meta"=>[
                "status"=>3,
                "msg"=>"注册失败"
            ]
        ];
    }
}
echo json_encode($arr);